//
//  CollectionViewController.h
//  liwo
//
//  Created by liuwenyang on 14-9-19.
//  Copyright (c) 2014年 liuwenyang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "CollectionViewCell.h"
@class CollectionViewController;
@protocol CollectionViewControllerDelegate <NSObject>

@optional
- (void)didClickElementForItem:(CollectionViewController *)controller element:(id)element data:(id)data;
//- (void)didSelectedCell:(CollectionViewController *)controller dataSrc:(id)dataSrc;
- (void)didSelectedCell:(CollectionViewController *)controller dataSrc:(id)dataSrc index:(NSIndexPath *)index;
-(UIView *)viewForcollectionView:(CollectionViewController *)viewForcollectionView;
- (void)collectionModelDidLoadFinished:(CollectionViewController *)controller;
@end


@interface CollectionViewController : NSObject<UICollectionViewDelegate, UICollectionViewDataSource,CollectionViewItemDelegate>
{
    UICollectionView *_collectionView;
    __weak id<CollectionViewControllerDelegate> _delegate;
}
@property (nonatomic, strong) NSString *identifierStr; //判断是哪个cell
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) NSMutableArray *dataSource;
@property (nonatomic, assign) NSInteger totalNumber;
@property (nonatomic, weak) id<CollectionViewControllerDelegate> delegate;
@property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout;
@property (nonatomic, strong) Class classForItem;
-(instancetype)initWithCellForItem:(Class)classForItem;
//-(Class)classForcell;

@end


@interface RefleshCollectionViewController : CollectionViewController
{
    NSUInteger pageIndex_;  //页码
}

-(id)initWithDragRefresh:(BOOL)enableDragRefresh withInfiniteScroll:(BOOL)enableInfiniteScroll classForItem:(Class)classForItem;

@property (nonatomic, assign) NSInteger totalPages;
@property (nonatomic, assign) NSUInteger pageIndex;
@property (nonatomic, assign) BOOL isAlreadyRefresh;
- (void)refreshTable:(void (^)(BOOL finished))block;
- (void)getTableMore:(void (^)(BOOL finished))block;

//强制模拟下拉刷新
- (void)forceRefresh;
@end




